﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RLRT.Common;
using RLRT.Models;

namespace RLRT.Web
{
    public partial class PickQuery : LocalPage
    {
        /// <summary>
        /// 页面加载
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                #region 验证权限

                #endregion

                #region 获取参数

                #endregion

                //初始化
                this.Initialize();
            }

            #region 页面标题

            this.Title = PageTitle.Text;

            #endregion

            #region 页面要素


            #endregion
        }

        #region 初始化

        /// <summary>
        /// 初始化
        /// </summary>
        private void Initialize()
        {
            #region 页面内容

            this.OrNoFrom.Text = string.Empty;
            this.OrNoTo.Text = string.Empty;
            this.BomNo.Text = string.Empty;
            this.BomName.Text = string.Empty;
            this.DateFrom.Text = DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd");
            this.DateTo.Text = DateTime.Now.ToString("yyyy-MM-dd");
            this.IsPick.Checked = false;
            this.IsScrap.Checked = false;

            #endregion

            //绑定列表
            //this.BindList();
        }

        #endregion

        #region 绑定数据

        /// <summary>
        /// 绑定列表
        /// </summary>
        private void BindList()
        {
            using (RTProvider rtProvider = new RTProvider())
            {
                List.DataSource = rtProvider.GetPickRecordList(OrNoFrom.Text.Trim(), OrNoTo.Text.Trim(), BomNo.Text.Trim(), BomName.Text.Trim(), DateFrom.Text.Trim(), DateTo.Text.Trim(), IsPick.Checked, IsScrap.Checked);
            }
            List.DataBind();
        }

        /// <summary>
        /// 翻页
        /// </summary>
        protected void List_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            List.PageIndex = e.NewPageIndex;
            this.BindList();
        }

        #endregion

        #region 操作

        /// <summary>
        /// 确定
        /// </summary>
        protected void OKButton_Click(object sender, EventArgs e)
        {
            this.BindList();
        }

        /// <summary>
        /// 取消
        /// </summary>
        protected void CancelButton_Click(object sender, EventArgs e)
        {
            this.Initialize();
        }

        /// <summary>
        /// 导出
        /// </summary>
        protected void ExportButtion_Click(object sender, EventArgs e)
        {
            this.List.AllowPaging = false;
            this.BindList();
            LocalGlobal.ToExcel(this.List, "领用查询");
            this.List.AllowPaging = true;
            this.BindList();
        }
        #endregion
    }
}